﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BL.BetterControls;

namespace BL.BIZControls
{
    public partial class ActionDropDown : System.Web.UI.UserControl
    {
        public event DoActionHandler DoAction;
        public _DropDownList ActionList { get { return ddlAction; } }
        public ListItemCollection Items { get { return ddlAction.Items; } }
        public string SelectedValue { get { return ddlAction.SelectedValue; } set { ddlAction.SelectedValue = value; } }
        public string Description { get { return btnAction.ToolTip; } set { btnAction.ToolTip = value; ddlAction.Description = value; } }

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected override void OnPreRender(EventArgs e)
        {
            //Bakåtkompatibelt med gamla kontroller som är gjorda för gå direkt mot ddlaction
            this.Visible = ddlAction.Visible;
    
            base.OnPreRender(e);
        }

        protected void btnAction_Click(object sender, EventArgs e)
        {

            if (DoAction != null)
            {
                if (ddlAction.SelectedValue != "-")
                {
                    DoAction(this, ddlAction.SelectedValue);
                }
            }
        }
    }
}